﻿using Quartz;
using System;
using System.Data;
using System.Data.Common;
using MyCode.Project.Services;
using MyCode.Project.Infrastructure;
using MyCode.Project.Infrastructure.UnityExtensions;
using Microsoft.Practices.Unity;
using System.Reflection;
using MyCode.Project.Domain.Model;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Threading;

namespace MyCode.Project.ScheduleTask.Jobs
{
	public class WeeHoursJob : IJob
    {

		private readonly IReportTaskService _reportTaskService;
        private IMillionShopExtensionService _millionShopExtensionService;
        private IReport2308Service _report2308Service;

        public WeeHoursJob(IReportTaskService reportTaskService
            , IMillionShopExtensionService millionShopExtensionService
              , IReport2308Service report2308Service
           )
		{
            _reportTaskService = reportTaskService;
            _millionShopExtensionService = millionShopExtensionService;
            _report2308Service = report2308Service;

        }


		public void Execute(IJobExecutionContext context)
        {
            _report2308Service.SaveAll2308TodayData();
            _reportTaskService.SetShopMonthKPI();//自动给店铺默认业绩计算方式
            _reportTaskService.AutoAudit();//自动审核昨日五项指标
            _reportTaskService.AutoSetKPI();//自动生成今日五项指标
            string daystring = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            _millionShopExtensionService.ShopPerformanceTask(daystring);
            _millionShopExtensionService.SendTodayKPI();//发送消息给店长、店员、加盟商:凌晨执行，发送昨天业绩信息
         

        }
    }
}

